<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>留言板</title>
<link rel="stylesheet" type="text/css" href="__static__/css/style.css" />
<script src="__static__/js/cufon-yui.js" type="text/javascript"></script>
<script src="__static__/js/Pristina_400.font.js" type="text/javascript"></script>
<script type="text/javascript">
	Cufon.replace('h1');
	Cufon.replace('.contact_row label');
</script>
</head>
<body>
{include file="./public/user/head.html" /}
<div style="margin-left: 70%;margin-top: 14%;">
    <button onclick="mess()" style="border: none;background-color: transparent">
    <font color="#8b4513" size="4" style="border: #633a1c;font-style: italic">去发表</font>
    </button>
</div>
<div id="main_container" style="margin-top: -250px">
    <div class="contact_form">
        <div id="tihuan">
            <ul >
                {volist name='mes' id='m'}
                <li style="font-size: large">
                    {$m.username}: {$m.content}<br>
                    <label style="margin-left: 250px">{$m.updatetime}</label>
                </li>
                {/volist}
            </ul>
        </div>

        <div class="list-page" align="center" id="page" >
            {for start="1" end="$pages+1" name="i" }
            <a href="javascript:;" onclick="jump({$i})" >{$i}</a>
            {/for}
            &nbsp;&nbsp;<em id="page_curr">共{$curr}/{$pages}页</em>
        </div>
    </div>
</div>
</body>
<!--发表留言-->
<script>
    $(function () {
        $('#send').click(function () {
            var title = $('#title').val();
            var content = $('#content').val();
            //验证签名
            sign.params = {
                title:title,
                content:content
            }
            var encode_data = sign.encode_post();
            console.log(encode_data);
            $.post(url_list.mes_add,encode_data,function (data) {
                //解码
                if(typeof data == 'string'){
                    data = eval('('+data+')');
                }
                data = sign.decode_post(data);
                console.log(data);
                //返回数组
                alert(data.msg);
            },'json')
        })
    })
</script>

<script>
//    <!--退出-->
    function logout() {
        location.href = url_list.logout;
    }
    <!--个人中心-->
    function info() {
        location.href = url_list.user_info;
    }
    //发表留留言
    function mess() {
        location.href = url_list.mes_index;
    }
    //分页内容替换
    function jump(page){
        var html = '';
        var page_curr='';
        //验证签名
        sign.params = {
            curr:page
        }
        var encode_data =sign.encode_post();
        console.log(encode_data);
        $.post(url_list.mes_list,encode_data,function (data){
            //解码
            if(typeof data == 'string'){
                data = eval('('+data+')');
            }
            data = sign.decode_post(data);
            console.log(data['data']['list']);

            list = data['data']['list'];
            curr = data['data']['curr'];
            for(var i in list){
                list[i].username         = list[i].username?list[i].username:'';
                list[i].content          = list[i].content?list[i].content:'';
                list[i].updatetime       = list[i].updatetime?list[i].updatetime:'';

                html+='<ul>';
                html+= '<li style="font-size: large">'
                    +list[i].username+'：'+list[i].content
                html+= '<br>';
                html+='<label style="margin-left: 250px">'+list[i].updatetime;
                html+='</label> </li></ul>';

                page_curr='共'+curr+'/{$pages}页';
            }
            //页面数据替换
            $('#tihuan').html(html);
            $('#page_curr').html(page_curr);
        },'json')
    }
</script>
</html>